import request from '@/router/axios';
import {baseUrl} from '@/config/env';

export const resetPassword = (ids) => {
  return request({
    url: baseUrl + '/api/user/resetpwd',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const getList = (page, limit, params) => {
  return request({
    url: baseUrl + '/api/user/getpages',
    method: 'get',
    params: {
      key:params.loginName==undefined?'':params.loginName,
      type:params.departmentId==undefined?'':params.departmentId,
      where:params.where==undefined?'':params.where,
      page,
      limit,
    }
  })
}

export const alluser = () => {
  return request({
    url: baseUrl + '/api/user/getpages',
    method: 'get',
	params: {
	  limit:999,
	}
  })
}
export const remove = (ids) => {
  return request({
    url: baseUrl + '/api/user/remove',
    method: 'post',
    params: {
      ids,
    }
  })
}

export const add = (row) => {
  return request({
    url: baseUrl + '/api/user/add',
    method: 'post',
    data: row
  })
}

export const update = (row) => {
  return request({
    url: baseUrl + '/api/user/edit',
    method: 'post',
    data: row
  })
}

export const getUser = (id) => {
  return request({
    url: baseUrl + '/api/user/detail',
    method: 'get',
    params: {
      id,
    }
  })
}

export const curUser = () => {
  return request({
    url: baseUrl + '/api/user/info',
    method: 'get'
  })
}

export const changePwd = (opwd,pwd) => {
  return request({
    url: baseUrl + '/api/user/changePwd',
    method: 'get',
    params: {
      opwd,
      pwd
    }
  })
}

export const getCodes = (tid) => {
  return request({
    url: baseUrl + '/api/user/getCodes',
    method: 'get',
    params: {
      typeId:tid,
    }
  })
}